﻿using ParboiledSharp.parboiled.dataobjects;

namespace ParboiledSharp.parboiled.rules
{
    class OneOrMore : ContainerRule
    {
        public OneOrMore(object rule)
        {
            SetRule(rule);
        }

        public OneOrMore()
        {
        }

        internal override bool Execute(Context context)
        {
            int count = 0;
            while (true)
            {
                bool result = ExecuteRule(GetRule(), context);
                if (result)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            return count > 0;
        }
    }
}
